package com.sairobo.admin.modules.srblive.controller;

import java.io.IOException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.sairobo.admin.modules.srblive.entity.SrbliveFileEntity;
import com.sairobo.admin.modules.srblive.pojo.param.PPTParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.sairobo.base.common.annotation.SysLog;
import com.sairobo.base.common.entity.Page;
import com.sairobo.base.common.entity.R;
import com.sairobo.admin.modules.srblive.service.SrbliveFileService;
import com.sairobo.base.modules.sys.controller.AbstractController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件目录
 *
 * @author admin
 * @email sairobo
 * @url www.sairobo.com
 * @date 2018年1月09日 上午10:41:05
 */
@RestController
@RequestMapping("/srblive/file")
public class SrbliveFileController extends AbstractController {
	
	@Autowired
	private SrbliveFileService srbliveFileService;
	
	/**
	 * 列表
	 * @param params
	 * @return
	 */
	@RequestMapping("/list")
	public Page<SrbliveFileEntity> list(@RequestBody Map<String, Object> params) {
		return srbliveFileService.listSrbliveFile(params);
	}
	
	@RequestMapping(value = "/springUpload", method = RequestMethod.POST)
	public R springUpload(HttpServletRequest request, @RequestParam(value = "file")MultipartFile file, PPTParam param)
            throws IllegalStateException, IOException, InstantiationException, IllegalAccessException {
		return srbliveFileService.multiUpload(request,file,param);
	}
		
	/**
	 * 新增
	 * @param srbliveFile
	 * @return
	 */
	@SysLog("新增文件目录")
	@RequestMapping("/save")
	public R save(@RequestBody SrbliveFileEntity srbliveFile) {
		return srbliveFileService.saveSrbliveFile(srbliveFile);
	}
	
	/**
	 * 根据id查询详情
	 * @param id
	 * @return
	 */
	@RequestMapping("/info")
	public R getById(@RequestBody Long id) {
		return srbliveFileService.getSrbliveFileById(id);
	}
	
	/**
	 * 修改
	 * @param srbliveFile
	 * @return
	 */
	@SysLog("修改文件目录")
	@RequestMapping("/update")
	public R update(@RequestBody SrbliveFileEntity srbliveFile) {
		return srbliveFileService.updateSrbliveFile(srbliveFile);
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@SysLog("删除文件目录")
	@RequestMapping("/remove")
	public R batchRemove(@RequestBody Long[] id) {
		return srbliveFileService.batchRemove(id);
	}
	
}
